import { TUseGcfxPage } from "@/gcfx_web/defaultConfig/config"
import { Input } from "antd"
import { IColumnsType } from "hy_dev_lib"
import { useState } from "react"

const useListUnitPriceQueryPage: TUseGcfxPage = (onSearch) => {
  const [proName, setProName] = useState<string>("")

  const extraSearchComponent = <div>
    项目名称：
    <Input
      value={proName}
      onChange={(e) => setProName(e.target.value)}
      onPressEnter={() => onSearch && onSearch()}
      style={{ width: 200, marginRight: 5 }}
    ></Input>
  </div>

  const getTableColumns = (columns: IColumnsType) => {
    const cols = [...columns]
    cols.splice(8, 0, {
      title: "项目名称",
      width: 120,
      dataIndex: "gcmc",
      ellipsis: true,
    })
    return cols
  }

  return {
    extraSearchComponent,
    extraSearchValues: { gcmc: proName },
    getTableColumns,
  }
}

export default useListUnitPriceQueryPage